Repository navigation
feat: add click-to-delete functionality for canvas connection lines - #145
Open
Kesarchauhan wants to merge 1 commit into
Open
Kesarchauhan wants to merge 1 commit into
Kesarchauhan wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NodeLine) on the flowsheet canvas, allowing users to inspect, select, and delete individual stream connections directly without removing connected unit operations or material streams.src/main/python/utils/Graphics.py):QtWidgets.QGraphicsItem.ItemIsSelectableandQtWidgets.QGraphicsItem.ItemIsFocusableflags alongside hover event tracking (setAcceptHoverEvents(True)) and left/right mouse button acceptance (Qt.LeftButton | Qt.RightButton) onNodeLine.NodeLine.shape()using a10.0px-wideQtGui.QPainterPathStrokeraround the orthogonal connection path so users can reliably hover over and click2pxlines without pixel-hunting, while preserving the draggable free-endpoint ellipse hit-box for partial/rerouted connections.NodeLine.paint()to render distinct visual states: a blue highlight (QColor(0, 123, 255),3pxstroke) on hover, a red highlight (QColor(220, 53, 69),3pxstroke) when selected, and the default teal stroke (QColor(0, 70, 70, 220),2pxstroke) otherwise.hoverEnterEvent()andhoverLeaveEvent()onNodeLineto drain any staleQApplicationoverride cursors left on the stack by socket connections and applyQtCore.Qt.PointingHandCursoracross bothQApplicationand theQGraphicsViewviewport, restoring the default cursor automatically when leaving or deleting a hovered line.src/main/python/utils/Graphics.py):NodeLine.mousePressEvent()to select the clicked connection line (clearing prior selection unlessCtrlis held) and assign keyboard focus (setFocus()), while keeping partial-line free-endpoint dragging intact.contextMenuEvent()onNodeLinethat selects the line and presents a Delete Connection action.keyPressEvent()handling onNodeLineso pressingDeleteorBackspacewhile a connection line is selected removes it immediately.NodeLine.delete_connection()routed throughContainer.delete([self])(with standalone fallback cleanup when no container is attached) so deleting a line cleanly detaches socket references (source.out_linesandtarget.in_lines), removes logical backend mappings (remove_connection(0, ...)andremove_connection(1, ...)), refreshes crossing hop arcs on neighboring lines, unlocks downstream component parameters viaupdate_components_editability(), and records a canvas snapshot forCtrl + ZUndo/Redo.tests/test_node_line_delete.py):tests/test_node_line_delete.pyverifying:ItemIsSelectableandItemIsFocusableflags and10pxQPainterPathStrokerhit-box containment (test_nodeline_is_selectable_and_has_wide_hitbox).paint()rendering for hovered and selected states (test_nodeline_hover_and_selection_paint).Container.delete([self])) removing the line from theQGraphicsScene, detaching socket lists, invokingremove_connectionon both connected unit operations, triggeringupdate_components_editability(), and pushing an undo snapshot (test_nodeline_delete_via_container_updates_editability).Qt.Key_Deletewhen the connection line is selected (test_nodeline_keyboard_delete_key).test_nodeline_context_menu_delete).test_deleting_one_line_preserves_other_connections).pytest --cov=python.utils.Graphics --cov-report=term-missing).Demo Screenshots